//
//  HotDetailController.m
//  BobNews
//
//  Created by lanou3g on 16/5/11.
//  Copyright © 2016年 YJC. All rights reserved.
//

#import "HotDetailController.h"
#import "NetWorkRequestManager.h"

@interface HotDetailController ()
@property (nonatomic,strong) NSString *urlStr;
//@property (nonatomic,strong) UIWebView *webView;
@end

@implementation HotDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor magentaColor];
    [self loadData];
    // Do any additional setup after loading the view.
}

- (void)loadData {
    
    [NetWorkRequestManager requestUrl:[NSURL URLWithString:[NSString stringWithFormat:@"http://c.m.163.com/nc/article/%@/full.html",self.model.docid]] RequestMethod:GET Params:nil Result:^(NSData *data, NSURLResponse *response, NSError *error) {
        if (data) {
            NSMutableDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
            NSDictionary *dataDict = jsonDict[self.model.docid];
            self.urlStr = dataDict[@"shareLink"];
            NSLog(@"%@",self.urlStr);
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            [self createWebView];
        });

    }];
}
- (void)createWebView {
    UIWebView *webView = [[UIWebView alloc]initWithFrame:self.view.bounds];
    [self.view addSubview:webView];
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlStr]]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
